import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
import { getIpCity, getSearch } from '@/api'
export const useOlStore = defineStore('openlayer', () => {
  //herder要用的数据
  const city = ref({})
  //选择的矢量图层类型
  const vecValue = ref('')
  //选择的标记图层类型
  const markValue = ref('')
  //缩放级别
  const zoomLevel = ref(4)
  //拉框查询的结果
  const searchPoint = ref({})
  //清除查询画笔的标记
  const clearSearchFlag = ref(0)

  //触发清理搜索的方法
  const flagclearSearch = () => {
    clearSearchFlag.value += 1
  }

  //矢量图层类型选项
  const vecOptions = ref([
    { value: 'LineString', label: '线' },
    { value: 'Polygon', label: '多边形' },
    { value: 'Circle', label: '圆' },
    { value: 'free', label: '自由绘制' },
    { value: 'clear', label: '清除绘制' },
  ])
  //标记图层类型选项
  const markOptions = ref([
    { value: 'park', label: '停车场' },
    { value: 'hospital', label: '医院' },
    { value: 'charger', label: '充电站' },
    { value: 'bus', label: '公交站' },
    // { value: 'clear', label: '清除绘制' },
  ])
  return {
    city,
    zoomLevel,
    vecValue,
    markValue,
    vecOptions,
    markOptions,
    searchPoint,
    clearSearchFlag,
    getIpCity,
    getSearch,
    flagclearSearch,
  }
})
